<?php

	// TITLE: Event_build AUTO MODEL
	// FILE: scaffolding/model/event_build.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createEventBuild = function($con, $eventBuild) {
		$sql = 'INSERT INTO event_build (event_id, project_id) VALUES (';
		$sql .= $event_build->getEventId() . ', ';
		$sql .= $event_build->getProjectId() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readEventBuild = function($con, $id) {
		$sql = 'SELECT * FROM event_build WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$eventBuild = new EventBuild();
			$eventBuild->setEventId($dbio->select($readEvent(result[0])));
			$eventBuild->setProjectId($dbio->select($readProject(result[1])));
		} else {
			$eventBuild = false;
		}
		return $eventBuild;
	};

	$updateEventBuild = function($con, $eventBuild) {
		$sql = 'UPDATE event_build SET ';
		$sql .= 'event_id = ' . $event_build->getEventId() . ', ';
		$sql .= 'project_id = ' . $event_build->getProjectId() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteEventBuild = function($con, $id) {
		$sql = 'DELETE FROM event_build WHERE event_id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listEventBuild = function($con) {
		$sql = 'SELECT * FROM event_build';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$eventBuilds = array();
			while ($result = mysqli_fetch_array($results)) {
				$eventBuild = new EventBuild();
				$eventBuild->setEventId($dbio->select($readEvent(result[0])));
				$eventBuild->setProjectId($dbio->select($readProject(result[1])));
				$eventBuilds[] = eventBuild;
			}// end while
		} else {
			$eventBuilds = false;
		}
		return $eventBuilds;
	};

